package hy;

import hy.beans.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main1(String[] args) {
        ApplicationContext a = new ClassPathXmlApplicationContext("u.xml");
        System.out.println(a.getBean("u1")==a.getBean("u1"));
    }

    public static void main2(String[] args)throws Exception {
        ClassPathXmlApplicationContext app=new ClassPathXmlApplicationContext("u.xml");
        System.out.println(app.getBean("a"));
//    容器销毁
        app.close();
        //也是执行销毁方法，跟上面区别：只有当本线程结束后才能执行销毁方法,上面是立刻执行销毁方法
//        app.registerShutdownHook();
        Thread.sleep(5000);
    }

    public static void main(String[] args) {
        ApplicationContext a = new ClassPathXmlApplicationContext("u1.xml");
        System.out.println(a.getBean("hello"));
    }
}
